<!DOCTYPE html>
<html lang="en">
<head>
    {% load staticfiles %}
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width">
    <title>{{ title }}</title>
    <!-- 新 Bootstrap 核心 CSS 文件 -->
    <link rel="stylesheet" href="http://cdn.bootcss.com/bootstrap/3.3.0/css/bootstrap.min.css">

    <!-- 可选的Bootstrap主题文件（一般不用引入） -->
    <link rel="stylesheet" href="http://cdn.bootcss.com/bootstrap/3.3.0/css/bootstrap-theme.min.css">
    <link rel="stylesheet" href={% static 'css/style.css' %}>
    <!-- jQuery文件。务必在bootstrap.min.js 之前引入 -->
    <script src="http://cdn.bootcss.com/jquery/1.11.1/jquery.min.js"></script>

    <!-- 最新的 Bootstrap 核心 JavaScript 文件 -->
    <script src="http://cdn.bootcss.com/bootstrap/3.3.0/js/bootstrap.min.js"></script>

    <script src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>
</head>
<body>
<div class="container">
    <div class="col-md-9">
        <div class="row ">
            <h2>我的小智</h2>
        </div>
        <div class="row">
            <div class="list-group">
                {% for device in device_list %}
                    <a href="./devicestatus/{{ device.device_type }}/{{ device.device_id }}" class="list-group-item">
                        {{ device.device_type }}
                    </a>
                {% endfor %}
                <a href="#" class="list-group-item">设备2</a>
                <a href="#" class="list-group-item">设备3</a>
                <a href="#" class="list-group-item">设备4</a>
                <a href="#" class="list-group-item">设备5</a>
            </div>

        </div>
        <div class="row">
            <a href="./adddevice" class="btn btn-primary btn-lg center-block">添加小智</a>
        </div>
    </div>

</div>


</body>

<script>
    var wx_cfg = {
        debug: false,
        appId: 'wxc933621a5d3df147',
        timestamp: {{wx_cfg.timestamp}},
        nonceStr: '{{wx_cfg.nonceStr}}',
        signature: '{{wx_cfg.signature}}',
        beta: true,
        jsApiList: [
            'openWXDeviceLib',
            'getWXDeviceTicket'
        ]
    }
    var str = JSON.stringify(wx_cfg);
    wx.config(wx_cfg);

    wx.ready(function () {
        //初始化设备库
{#        alert('开始初始化设备库');#}
        wx.invoke('openWXDeviceLib', {}, function (res) {
            var str = JSON.stringify(res);
{#            alert('openWXDeviceLib' + str);#}
            wx.invoke('getWXDeviceTicket', {"deviceId": 'gh_f96f28ef7669_d11d3e1aa92829f0', "type": 1}, function (res) {
                var str = JSON.stringify(res);
                alert('getWXDeviceTicket' + str);
            });
        });

    });

    wx.error(function (res) {
        var str = JSON.stringify(res);
        alert('wx.error' + str);
    });
</script>

</html>